package org.itzixi.netty.single;

import io.netty.channel.group.ChannelGroup;
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.util.concurrent.GlobalEventExecutor;

public class ChannelGroupSingleton {
    private static volatile ChannelGroup clients;




    private ChannelGroupSingleton(){

    }

    public static ChannelGroup getInstance(){
        if (clients == null){
            synchronized (ChannelGroupSingleton.class){
                if (clients == null){
                    clients = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
                }
            }
        }
        return clients;
    }


//    private ChannelGroupSingleton() {
//
//    }
//
//    public static ChannelGroup getInstance(){
//        return Singleton.HOLDER.clients;
//    }
//
//    private enum Singleton {
//        HOLDER;
//        private final ChannelGroup clients ;
//
//
//
//        Singleton(){
//            clients = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
//        }
//    }
}
